﻿<UserControl x:Class="SPIWareMVVM.Reports.WorkOrderReport"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:converters="clr-namespace:SPIWareMVVM.Views.Conversions"
             xmlns:rules="clr-namespace:SPIWareMVVM.Views.ValidationRules"
             mc:Ignorable="d" 
             xmlns:my="clr-namespace:SPIWareMVVM.Reports" d:DesignHeight="960" d:DesignWidth="720">
    <Control.Resources>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="HorizontalAlignment" Value="Right"/>
            <Setter Property="FontSize" Value="12"/>
        </Style>
        <Style x:Key="TextBlkStyle" TargetType="{x:Type TextBlock}">
            <Setter Property="FontSize" Value="14"/>
        </Style>
        <Style x:Key="LargeTextBlkStyle" TargetType="{x:Type TextBlock}">
            <Setter Property="FontSize" Value="24"/>
        </Style>
        <Style x:Key="LargeCenteredText" TargetType="{x:Type TextBlock}">
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="FontSize" Value="24"/>
        </Style>
        <Style x:Key="LargeColumnHeader" TargetType="{x:Type TextBlock}">
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="FontSize" Value="24"/>
            <Setter Property="TextDecorations" Value="Underline"/>
        </Style>
        <converters:BoxesNeededConverter x:Key="boxesNeededConverter"/>
        <converters:PalletsNeededConverter x:Key="palletsNeededConverter"/>
        <converters:BoxesPerPalletConverter x:Key="boxesPerPalletConverter"/>
    </Control.Resources>
    <!-- 96 pixels per inch == 720 x 960 .5" margins-->
    <DockPanel x:Name="dpReport" Height="864" Width="624" HorizontalAlignment="Center">
        <my:ReportsHeader DockPanel.Dock="Top" x:Name="reportsHeader1" SubTitle="Production Work Order"/>
        <StackPanel x:Name="dataView" Orientation="Vertical">
            <TextBlock Height="14" />
            <DockPanel x:Name="BoldBlockOnRight">
                <Grid DockPanel.Dock="Right">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <TextBlock Style="{StaticResource LargeTextBlkStyle}" Grid.Column="0" Grid.Row="0" Text="Work Order # "/>
                    <TextBlock Style="{StaticResource LargeTextBlkStyle}" Grid.Column="1" Grid.Row="0" Text="{Binding WorkOrderId}"/>

                    <TextBlock Style="{StaticResource LargeTextBlkStyle}" Grid.Column="0" Grid.Row="1" Text="Quantity: " />
                    <TextBlock Style="{StaticResource LargeTextBlkStyle}" Grid.Column="1" Grid.Row="1" Text="{Binding oQuantity}"/>

                    <TextBlock Style="{StaticResource LargeTextBlkStyle}" Grid.Column="0" Grid.Row="2" Text="Target Cycle Time: " />
                    <TextBlock Style="{StaticResource LargeTextBlkStyle}" Grid.Column="1" Grid.Row="2" Text="{Binding Part.TargetCycleTime}" />

                    <TextBlock Style="{StaticResource TextBlkStyle}" Grid.Column="0" Grid.Row="3" Text="Date Due: " />
                    <TextBlock Style="{StaticResource TextBlkStyle}" Grid.Column="1" Grid.Row="3" Text="{Binding DateDue, StringFormat={}{0:MM/dd/yyyy}}" />
                </Grid>
                <TextBlock Text=""/>
            </DockPanel>
            <TextBlock Height="14" />
            <Grid x:Name="CustomerInformation" DockPanel.Dock="Top">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="85"/>
                    <ColumnDefinition Width="125"/>
                    <ColumnDefinition Width="5"/>
                    <ColumnDefinition Width="105"/>
                    <ColumnDefinition Width="125"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <TextBlock Grid.Column="0" Grid.Row="0" Text="Customer: " />
                <TextBlock Grid.Column="0" Grid.Row="1" Text="Part # " />
                <TextBlock Grid.Column="0" Grid.Row="2" Text="Description: " />

                <TextBlock Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left" Text="{Binding Customer.Name}" />
                <TextBlock Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left" Text="{Binding Part.PartNumber}" />
                <TextBlock Grid.Column="1" Grid.Row="2" HorizontalAlignment="Left" Text="{Binding Part.Description}" />

                <TextBlock Grid.Column="3" Grid.Row="0" Text="Date Received: " />
                <TextBlock Grid.Column="3" Grid.Row="1" Text="Customer PO # " />
                <TextBlock Grid.Column="3" Grid.Row="2" Text="Quantity: " />

                <TextBlock Grid.Column="4" Grid.Row="0" HorizontalAlignment="Left" Text="{Binding DateReceived, StringFormat={}{0:MM/dd/yyyy}}" />
                <TextBlock Grid.Column="4" Grid.Row="1" HorizontalAlignment="Left" Text="{Binding CustomerPO}" />
                <TextBlock Grid.Column="4" Grid.Row="2" HorizontalAlignment="Left">
                    <TextBlock.Text>
                        <Binding Path="oQuantity">
                            <Binding.ValidationRules>
                                <rules:EmptyStringRule/>
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBlock.Text>
                </TextBlock>
            </Grid>
            <TextBlock Height="12"/>
            <TextBlock Style="{StaticResource TextBlkStyle}" Text="Part Information" />
            <TextBlock Height="12"/>
            <Grid x:Name="PartInformation" DockPanel.Dock="Top">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="95"/>
                    <ColumnDefinition Width="125"/>
                    <ColumnDefinition Width="5"/>
                    <ColumnDefinition Width="125"/>
                    <ColumnDefinition Width="85"/>
                    <ColumnDefinition Width="5"/>
                    <ColumnDefinition Width="125"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <TextBlock Grid.Column="0" Grid.Row="0" Text="Resin Type: " />
                <TextBlock Grid.Column="0" Grid.Row="1" Text="Dye Color # " />
                <TextBlock Grid.Column="0" Grid.Row="2" Text="Mix Ratio %" />
                <TextBlock Grid.Column="0" Grid.Row="3" Text="Drawing #" />
                <TextBlock Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left" Text="{Binding Part.MaterialType}" />
                <TextBlock Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left" Text="{Binding Part.DyeNumber}" />
                <TextBlock Grid.Column="1" Grid.Row="2" HorizontalAlignment="Left" Text="{Binding Part.DyeMixRatio}" />
                <TextBlock Grid.Column="1" Grid.Row="3" HorizontalAlignment="Left" Text="{Binding Part.DrawingNumber}" />

                <TextBlock Grid.Column="0" Grid.Row="5" Text="Part Weight: " />
                <TextBlock Grid.Column="0" Grid.Row="6" Text="Parts Per Shot: " />
                <TextBlock Grid.Column="0" Grid.Row="7" Text="Shot Weight: " />
                <TextBlock Grid.Column="1" Grid.Row="5" HorizontalAlignment="Left" Text="{Binding Part.PartWeight}" />
                <TextBlock Grid.Column="1" Grid.Row="6" HorizontalAlignment="Left" Text="{Binding Part.PartsPerShot}" />
                <TextBlock Grid.Column="1" Grid.Row="7" HorizontalAlignment="Left" Text="{Binding Part.ShotWeight}" />

                <TextBlock Grid.Column="3" Grid.Row="0" Text="Press Size: " />
                <TextBlock Grid.Column="3" Grid.Row="1" Text="Mold # " />
                <TextBlock Grid.Column="3" Grid.Row="2" Text="Target Cycle Time: " />
                <TextBlock Grid.Column="3" Grid.Row="3" Text="Box Size: " />
                <TextBlock Grid.Column="3" Grid.Row="4" Text="Parts Per Box: " />
                <TextBlock Grid.Column="3" Grid.Row="5" Text="Boxes Per Pallet: " />
                <TextBlock Grid.Column="3" Grid.Row="6" Text="Parts per Pallet: " />
                <TextBlock Grid.Column="3" Grid.Row="7" Text="Part Packaging: " />
                <TextBlock Grid.Column="4" Grid.Row="0" HorizontalAlignment="Left" Text="{Binding Part.PressSize}" />
                <TextBlock Grid.Column="4" Grid.Row="1" HorizontalAlignment="Left" Text="{Binding Part.MoldNumber}" />
                <TextBlock Grid.Column="4" Grid.Row="2" HorizontalAlignment="Left" Text="{Binding Part.TargetCycleTime}" />
                <TextBlock Grid.Column="4" Grid.Row="3" HorizontalAlignment="Left" Text="{Binding Part.BoxSize}" />
                <TextBlock Grid.Column="4" Grid.Row="4" HorizontalAlignment="Left" >
                    <TextBlock.Text>
                        <Binding Path="PartsPerBox" x:Name="partsPerBox">
                            <!--<Binding.ValidationRules>
                                <rules:EmptyStringRule/>
                            </Binding.ValidationRules>-->
                        </Binding>
                    </TextBlock.Text>
                </TextBlock>
                <TextBlock Grid.Column="4" Grid.Row="5" HorizontalAlignment="Left" DataContext="{Binding Part}">
                    <TextBlock.Text>
                        <MultiBinding Converter="{StaticResource boxesPerPalletConverter}">
                            <Binding Path="PartsPerPallet"/>
                            <Binding Path="PartsPerBox"/>
                        </MultiBinding>
                    </TextBlock.Text>
                </TextBlock>

                <TextBlock Grid.Column="4" Grid.Row="6" HorizontalAlignment="Left" Text="{Binding Part.PartsPerPallet}" x:Name="partsPerPallet" />
                <TextBlock Grid.Column="4" Grid.Row="7" Text="{Binding Part.PackagingPerPart}" />

                <TextBlock Grid.Column="6" Grid.Row="0" Text="Shots Needed: " />
                <TextBlock Grid.Column="6" Grid.Row="2" Text="Average Cycle Time " />
                <TextBlock Grid.Column="6" Grid.Row="3" Text=" After Scrap: " />
                <TextBlock Grid.Column="7" Grid.Row="0" HorizontalAlignment="Left" Text="{Binding ShotsNeeded}" />
                <TextBlock Grid.Column="7" Grid.Row="3" HorizontalAlignment="Left" Text="{Binding Part.AverageCycleTime_AS}" />
            </Grid>

            <TextBlock Height="24"/>
            <DockPanel x:Name="MaterialsNeeded">
                <Grid DockPanel.Dock="Top" HorizontalAlignment="Center">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <TextBlock Style="{StaticResource LargeTextBlkStyle}" Grid.Column="0" Grid.ColumnSpan="2" Text="Materials Needed" />
                    <TextBlock  Style="{StaticResource LargeTextBlkStyle}" Grid.Column="0" Grid.Row="1" Text="Boxes: " />
                    <TextBlock  Style="{StaticResource LargeTextBlkStyle}" Grid.Column="0" Grid.Row="2" Text="Pallets: " />
                    <TextBlock  Style="{StaticResource LargeTextBlkStyle}" Grid.Column="1" Grid.Row="1" Text="{Binding BoxesNeeded}"/>
                    <!--<TextBlock.Text>
                        <MultiBinding Converter="{StaticResource boxesNeededConverter}">
                            <Binding Path="Text" ElementName="oQuantity"/>
                            <Binding Path="Text" ElementName="PartsPerBox"/>
                        </MultiBinding>
                    </TextBlock.Text>
                    </TextBlock>-->
                    <TextBlock  Style="{StaticResource LargeTextBlkStyle}" Grid.Column="1" Grid.Row="2" Text="{Binding PalletsNeeded}"/>
                    <!--<TextBlock.Text>
                            <MultiBinding Converter="{StaticResource palletsNeededConverter}">
                                <Binding Path="Text" ElementName="BoxesPerPallet"/>
                                <Binding Path="Text" ElementName="oQuantity"/>
                            </MultiBinding>
                        </TextBlock.Text>
                    </TextBlock>-->
                </Grid>
                <TextBlock DockPanel.Dock="Top" Height="24"/>
                <Border BorderBrush="Black" CornerRadius="20" BorderThickness="2">
                    <Grid DockPanel.Dock="Top" HorizontalAlignment="Center">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="200"/>
                            <ColumnDefinition Width="200"/>
                            <ColumnDefinition Width="200"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="14"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="14"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <TextBlock Style="{StaticResource LargeColumnHeader}" Grid.Row="0"  Grid.Column="0" Grid.ColumnSpan="3" Text="{Binding Customer.Name}" />
                        <TextBlock Style="{StaticResource LargeCenteredText}" Grid.Row="1"  Grid.Column="0" Grid.ColumnSpan="3" Text="{Binding Description}"/>

                        <TextBlock Style="{StaticResource LargeColumnHeader}" Grid.Column="0" Grid.Row="3" Text="Part #" />
                        <TextBlock Style="{StaticResource LargeColumnHeader}" Grid.Column="1" Grid.Row="3" Text="Work Order #" />
                        <TextBlock Style="{StaticResource LargeColumnHeader}" Grid.Column="2" Grid.Row="3" Text="Quantity" />

                        <TextBlock Style="{StaticResource LargeCenteredText}" Grid.Column="0" Grid.Row="4" Text="{Binding Part.PartNumber}" />
                        <TextBlock Style="{StaticResource LargeCenteredText}" Grid.Column="1" Grid.Row="4" Text="{Binding WorkOrderId}" />
                        <TextBlock Style="{StaticResource LargeCenteredText}" Grid.Column="2" Grid.Row="4" Text="{Binding oQuantity}" />

                        <TextBlock Style="{StaticResource LargeColumnHeader}" Grid.Column="0" Grid.Row="6" Text="Material" />
                        <TextBlock Style="{StaticResource LargeColumnHeader}" Grid.Column="2" Grid.Row="6" Text="Color / Dye" />

                        <TextBlock Style="{StaticResource LargeCenteredText}" Grid.Column="0" Grid.Row="7" Text="{Binding Part.MaterialType}" />
                        <TextBlock Style="{StaticResource LargeCenteredText}" Grid.Column="2" Grid.Row="7" Text="{Binding Part.DyeNumber}" />

                        <TextBlock Style="{StaticResource LargeCenteredText}" Grid.Column="1" Grid.Row="8" Text="{Binding DateDue, StringFormat={}{0:MM/dd/yyyy}}" />
                    </Grid>
                </Border>
            </DockPanel>
        </StackPanel>
    </DockPanel>
</UserControl>
